package com.example.service;

import com.example.handlers.SysHandler;
import com.example.po.SysJob;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class SysJobHandlerProxyServiceImpl implements SysJobHandlerProxyService {

    @Resource
    private List<SysHandler> sysHandlers = new ArrayList<>();

    @Override
    public void handler(SysJob sysJob) throws Exception {
        for (SysHandler sysHandler : sysHandlers) {
            if (sysHandler.isMatch(sysJob)) {
                sysHandler.handler(sysJob);
            }
        }
    }
}
